import random
import string

from hongruan import Address


class BankAccount:

    #构造函数
    def __init__(self,card_type:int,name:str,password:int,address:Address,balance:int,bank_name:str):
        self.account=''.join(random.choices(string.digits, k=8))
        self.type=card_type
        self.name=name
        # if not len(password) == 6:  #存在前导0的问题
        if not (100000 <= password <= 999999):
            raise ValueError("请输入6位密码")
        self.password=password
        self.address=address
        self.balance=balance
        self.bank_name=bank_name


    #全部输出
    def __str__(self):
        return (f"账号: {self.account_number}\n"
                f"账户类型: {self.account_type}\n"
                f"姓名: {self.name}\n"
                f"地址: {self.address}\n"
                f"存款余额: {self.balance}\n"
                f"开户行: {self.bank_name}")